import { createApp } from 'vue'
import App from './App.vue'
import router from './router/index'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import './assets/main.css'
import axios from 'axios';

// 配置 Axios 基础 URL
axios.defaults.baseURL = 'http://localhost:8080/api';

// 配置 Axios 拦截器
axios.interceptors.request.use(config => {
    const token = localStorage.getItem('token'); // 获取token
    if (token) {
        config.headers.Authorization = `Bearer ${token}`;
    }
    return config;
}, error => {
    return Promise.reject(error);
});

const app = createApp(App)
app.use(router)
app.use(ElementPlus)
app.config.globalProperties.$axios = axios;
app.mount('#app')
